home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-04-16 | 12.5 KB | 412 lines | [TEXT/MPS ] |
- %!
- % This is the prolog used by OzTeX 1.9 to convert a DVI file into PostScript.
- % Uncomment the following line to prevent a timeout error when creating
- % missing PK fonts.
-
- % statusdict begin /waittimeout 0 def end
-
- % Set dev to "LW" if LaserWriter, "LINO" if Linotronic, or "?" if unknown.
-
- /dev (?) def
- statusdict /product known {
- statusdict /product get
- (LaserWriter) anchorsearch { pop pop /dev (LW) def } { pop } ifelse
- statusdict /product get
- (Linotype) anchorsearch { pop pop /dev (LINO) def } { pop } ifelse
- } if
-
- /@setup { % set up OzTeX's coordinate system
-
- /res exch def % desired resolution (defines dots per inch)
- /voff exch def % vertical offset (in dots)
- /hoff exch def % horizontal offset (in dots)
- /ht exch def % paper height (in dots)
- /wd exch def % paper width (in dots)
-
- /land wd ht gt def % print in landscape orientation?
- /oshift ht res sub neg def % vertical shift (in dots) for portrait origin
-
- dev (?) eq % unknown device?
- { land
- { % landscape
- 90 rotate % rotate axes 90deg anticlockwise
- 72 res div dup neg scale % units now device dots
- res dup translate % move to TeX origin
- voff neg hoff translate % adjust TeX origin if necessary
- }
- { % portrait
- 72 res div dup neg scale % units now device dots
- res oshift translate % move to TeX origin
- hoff voff translate % adjust TeX origin if necessary
- } ifelse
- } if
-
- dev (LW) eq % LaserWriter?
- {
- % Display model and version in OzTeX window.
- % (\rmodel = ) print statusdict /product get print
- % (\rversion = ) print version print (\r) print flush
-
- land
- { % landscape
- 90 rotate % rotate axes 90deg anticlockwise
- 72 res div dup neg scale % units now device dots
- res dup translate % move to TeX origin
- voff neg hoff translate % adjust TeX origin if necessary
-
- % Model-specific adjustments to origin can be made here.
- statusdict /product get (LaserWriter) eq
- { -90 0 translate % move left a bit
- }
- { statusdict /product get (LaserWriter Plus) eq
- { -32 0 translate % move left a bit
- }
- { statusdict /product get (LaserWriter II NTX) eq
- { -20 0 translate % move left a bit
- }
- { statusdict /product get (LaserWriter IIg) eq
- { 0 0 translate
- }
- { % some other model
- 0 0 translate
- }
- ifelse } ifelse } ifelse } ifelse
- }
- { % portrait
- 72 res div dup neg scale % units now device dots
- res oshift translate % move to TeX origin
- hoff voff translate % adjust TeX origin if necessary
-
- % Model-specific adjustments to origin can be made here.
- statusdict /product get (LaserWriter) eq
- { 0 22 translate % move down a bit
- }
- { statusdict /product get (LaserWriter Plus) eq
- { 0 0 translate
- }
- { statusdict /product get (LaserWriter II NTX) eq
- { 0 14 translate % move down a bit
- }
- { statusdict /product get (LaserWriter IIg) eq
- { 0 0 translate
- }
- { % some other model
- 0 0 translate
- }
- ifelse } ifelse } ifelse } ifelse
- } ifelse
-
- % The matrix produced above can cause rule alignment problems,
- % so round each matrix value to nearest integer.
-
- matrix currentmatrix
- dup dup 0 get round cvi 0 exch put
- dup dup 1 get round cvi 1 exch put
- dup dup 2 get round cvi 2 exch put
- dup dup 3 get round cvi 3 exch put
- dup dup 4 get round cvi 4 exch put
- dup dup 5 get round cvi 5 exch put
- setmatrix
-
- % Display new matrix in OzTeX window.
-
- % matrix currentmatrix
- % dup 0 get ( ) cvs print ( ) print
- % dup 1 get ( ) cvs print ( ) print
- % dup 2 get ( ) cvs print ( ) print
- % dup 3 get ( ) cvs print ( ) print
- % dup 4 get ( ) cvs print ( ) print
- % dup 5 get ( ) cvs print (\r) print flush
- % pop
- } if
-
- dev (LINO) eq % Linotronic?
- { land
- { % landscape
- 90 rotate % rotate axes 90deg anticlockwise
- 72 res div dup neg scale % units now device dots
- res dup translate % move to TeX origin
- voff neg hoff translate % adjust TeX origin if necessary
- }
- { % portrait
- newpath clippath pathbbox % push LLx LLy URx URy (URy = ht in pts)
- /paperht exch 72 div def % paper height in inches
- pop pop pop % remove URx LLy LLx
- 72 res div dup neg scale % units now device dots
- res paperht res mul neg res add
- translate % move to TeX origin
- hoff voff translate % adjust TeX origin if necessary
- } ifelse
- } if
-
- % Some fine-tuning of the code used to draw a rule may be necessary.
- % Use page 18 in nasty.dvi to check the results.
-
- dev (LW) eq % LaserWriter?
- { version cvr 38.0 le % early model?
- { land
- { % landscape
- /r % set a wd by ht rule at h,v
- { newpath
- moveto % move to h,v
- /ht exch 1 sub def % reduce height by 1
- /wd exch 1 sub def % ditto for width
- wd 0 rlineto
- 0 ht neg rlineto
- wd neg 0 rlineto
- fill
- } bind def
- }
- { % portrait
- /r % set a wd by ht rule at h,v
- { newpath
- 1 add moveto % move to h,v+1
- /ht exch 1 sub def % reduce height by 1
- /wd exch 1 sub def % ditto for width
- wd 0 rlineto
- 0 ht neg rlineto
- wd neg 0 rlineto
- fill
- } bind def
- } ifelse
- } if
- version cvr 2000.0 gt % IIg or newer model?
- {
- /r % set a wd by ht rule at h,v
- { newpath
- 1 add moveto % move to h,v+1
- /ht exch def % set height
- /wd exch def % set width
- wd 0 rlineto
- 0 ht neg rlineto
- wd neg 0 rlineto
- fill
- } bind def
- } if
- } if
-
- /mtrx 6 array def
- mtrx currentmatrix pop % save our new transformation matrix
-
- } def % @setup
-
- % @saveVM and @restoreVM are only used if we are conserving VM
- % by downloading font bitmaps more often.
-
- /@saveVM {/prefontVM save def} def
- /@restoreVM {prefontVM restore} def
-
- /newPKfont % create new PK font
- { /maxchcode exch def
- /fontid exch def
- fontid 7 dict def
- fontid load begin
- /FontType 3 def
- /FontMatrix [1 0 0 -1 0 0] def
- /FontBBox [0 0 1 1] def
- /BitMaps maxchcode 1 add array def
- /BuildChar {CharBuilder} def
- /Encoding 256 array def
- 0 1 255 {Encoding exch /.notdef put} for
- end
- fontid fontid load definefont pop
- } def
-
- % The char data, a bitmap descriptor, is an array with 6 elements;
- % element 0 is either a hex string or an array of hex strings (the latter
- % is required for large PK chars with more than 65535 hex digits).
-
- /ch-image {ch-data 0 get dup type /stringtype ne {N get /N N 1 add def} if
- } def % hex string
- /ch-width {ch-data 1 get} def % the number of pixels across
- /ch-height {ch-data 2 get} def % the number of pixels tall
- /ch-xoff {ch-data 3 get} def % number of pixels to left of origin
- /ch-yoff {ch-data 4 get} def % number of pixels below origin
- /ch-advw {ch-data 5 get} def % advance width
-
- % The following character builder looks up the char data in the BitMaps array
- % and paints the character.
-
- /CharBuilder % image one char
- { /ch-code exch def % save the char code
- /font-dict exch def % and the font dict
- /ch-data font-dict /BitMaps get
- ch-code get def
- /N 0 def
- ch-advw 0
- ch-xoff neg ch-height ch-yoff sub 1 sub neg % -xo , -(ht-yo-1)
- ch-width ch-xoff sub 1 sub ch-yoff % (wd-xo-1) , yo
- setcachedevice
- ch-width ch-height true
- [1 0 0 -1 ch-xoff ch-yoff] % bitmap sent top to bottom
- {ch-image}
- imagemask
- } def
-
- /sf {setfont} def % set current font
-
- /dc % define new character
- { /ch-code exch def
- /ch-data exch def
- currentfont /BitMaps get ch-code ch-data put
- currentfont /Encoding get ch-code
- dup ( ) cvs cvn put % generate unique name
- } bind def
-
- /@bop0 {pop} def % begin DVI page n
-
- /@bop1 % begin setting DVI page n
- { pop % throw away page number
- initgraphics % start with a clean slate
- mtrx setmatrix % switch to our TeX coordinate system
- /prepageVM save def % save state of VM at start of page
- } def
-
- /@eop % end DVI page n
- { pop % throw away page number
- prepageVM restore % restore VM to state at start of page
- showpage
- } def
-
- /@end { } def % end of file
-
- % h and s are used to typeset downloaded bitmap fonts.
-
- /h {exch 0 rmoveto show} bind def % move right by dh and show (...)
-
- /s {3 1 roll moveto show} bind def % move to h,v and show (...)
-
- % H and S are used to typeset PostScript fonts.
- % We can't use relative horizontal positioning because the advance widths in
- % a PostScript font are not integers and rounding errors would accumulate.
-
- /H {exch v moveto show} bind def % move to h,v and show (...)
-
- /S % ditto, and save v position
- { 3 1 roll
- 1 add % v+1 to match baseline of bitmap fonts
- dup /v exch def
- moveto show
- } bind def
-
- % r is used to typeset a rule.
-
- /r % set a wd by ht rule at h,v
- { newpath
- moveto % move to h,v
- /ht exch 1 sub def % reduce height by 1
- /wd exch 1 sub def % ditto for width
- wd 0 rlineto
- 0 ht neg rlineto
- wd neg 0 rlineto
- fill
- } bind def
-
- % Following 2 procedures are invoked as the result of \special{file}.
-
- /@bsp
- { /vmag exch def % vertical scaling
- /hmag exch def % horizontal scaling
- moveto % move to h,v
- /prespecialVM save def % save showpage, TeX procedures etc.
- userdict begin % push userdict on dict stack
- /showpage { } def % user does not have to remove showpage
- currentpoint transform
- initgraphics itransform translate % move 0,0 to h,v
- hmag vmag scale
- land { 90 rotate } if % rotate axes if landscape
- } bind def
-
- /@esp
- { end % pop userdict
- prespecialVM restore % restore saved showpage value etc
- } bind def
-
- % Following 2 procedures are invoked as the result of \special{epsf=file}.
-
- /@bepsf
- { /lly exch def % LLy for BoundingBox
- /llx exch def % LLx for BoundingBox
- /vmag exch def % vertical scaling
- /hmag exch def % horizontal scaling
- /vpos exch def % v pos of \special box
- /hpos exch def % h pos of \special box
- /prespecialVM save def % save showpage, TeX procedures etc
- userdict begin % push userdict on dict stack
- /showpage { } def % user does not have to remove showpage
- hpos vpos translate % move 0,0 to h,v
- hmag vmag scale % scale BoundingBox
- llx neg lly neg translate % move LLx,LLy to h,v
- } bind def
-
- /@eepsf
- { end % pop userdict
- prespecialVM restore % restore saved showpage value etc
- } bind def
-
- % Here is the code to handle bitmaps generated by PICT/PNTG \specials.
-
- /@bitmap
- { /vmag exch def % vertical scaling
- /hmag exch def % horizontal scaling
- /vres exch def % vertical resolution of bitmap
- /hres exch def % horizontal resolution of bitmap
- /ht exch def % height
- /wd exch def % width
- /hexstring ht string def
- gsave
- 1 add translate % set origin to h,v+1
- res hres div wd mul hmag mul
- res vres div ht mul vmag mul neg scale
- wd ht true
- [ wd 0 0 ht neg 0 ht ]
- { currentfile hexstring readhexstring pop }
- imagemask
- grestore
- } def
-
- % Here are the definitions needed to handle PostScript fonts.
-
- /namestr 60 string def % for names
- /numstr 12 string def % for numbers
-
- /newPSfont % create new PS font
- { /fontname exch def % printer font name
- /mag exch def % DVI mag
- /scaledpts exch def % font size in scaled pts
-
- % Use scaledpts and mag to calculate font size in device dots.
- scaledpts 16#10000 div % scaled pts to pts
- res mul 72.27 div % pts to device dots
- mag 1000 div mul % scale by mag/1000
- /dotsize exch def
- /done false def
-
- % If fontname starts with "Slanted-" then construct slanted font.
- fontname namestr cvs (Slanted-) anchorsearch
- { pop cvn findfont [1 0 .167 -1 0 0] makefont dotsize scalefont
- /done true def
- }{ pop } ifelse
-
- % Other nice tricks can be included here if you build the required
- % fonts and add appropriate printer font names to your config file.
- % fontname namestr cvs (Extended-) anchorsearch
- % { pop cvn findfont [1.2 0 0 -1 0 0] makefont dotsize scalefont
- % /done true def
- % }{ pop } ifelse
-
- done not
- { fontname findfont [1 0 0 -1 0 0] makefont dotsize scalefont
- } if
-
- % Modified font dictionary is on stack, so remember it for later setfont
- % via a unique name that is the concatenation of fontname and scaledpts.
- fontname length scaledpts numstr cvs length add
- /newname exch string def
- newname 0 fontname namestr cvs putinterval
- newname fontname length scaledpts numstr cvs putinterval
- newname cvn exch def
- } bind def
-
- % --- end of OzTeX's prolog ---
-